<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script>
    const  users = [{username:'user1',password:'password1'},
        {username:'user2',password:'password2'},
        {username:'user3',password:'password3'}];

    function authenticateUser(username, password){
        return new Promise((resolve,reject  )=>{
            setTimeout(()=>{
                const  user = users.find(user => user.username === username && user.password===password);
                if (user){
                    resolve(uesr);

                }else {
                    reject(new Error('Invalid username or password'));

                }

            },1000);

        });

    }

    authenticateUser(('uesr1','password1').then(user=>{
        console.log(`Welcome, ${user.username}!`);
    }).catch(error=>{console.error(error.message);}));
</script>
</html>